
import h5py

path_directory = '../data/matrix_suite_tar/'


sparse_name_list = ['gen2', '176bit', 'bcsstk13', 'biplane-9', 't2d_q9', 'fv2', 'fv3', 'big_dual', 
                    'ch7-8-b3', 'luxembourg_osm', 'cond-mat-2003', 'astro-ph', 
                    'wing', 'TSOPF_RS_b39_c7', 'airfoil_2d', 'jan99jac120sc', 
                    '3D_28984_Tetra', 'rajat25', 'c-69', 'rajat16', 'Trec13', 
                    'Zd_Jac2_db', 'bibd_17_8', 'image_interp', 'net4-1', 'tsyl201', 
                    'matrix-new_3', 'ct20stif', 'stat96v2', 'belgium_osm', 'Chevron3', 'parabolic_fem']

# density_map_all = []
# nnz_number_all = []
manual_feature_all = []

# f = open(f'sample_data_400.txt')
# for line_id, line in enumerate(f.readlines()):
#     sparse_name = line.strip('\n')
    
for sparse_name in sparse_name_list:
    print(sparse_name)
    
    # filename_h5py = path_directory + f'{sparse_name}/' + sparse_name + ".h5py"
    # print('#loading dataset', filename_h5py, '...')
    # cache = h5py.File(filename_h5py, 'r')
    # density_map = cache['density_map'][()]
    # print('#density_map:', density_map.shape, density_map.dtype)
    # nnz_number = cache['nnz_number'][()]
    # cache.close()
    
    filename_csv_h5py = path_directory + f'{sparse_name}/' + sparse_name + "_csv.h5py"
    cache = h5py.File(filename_csv_h5py, 'r')
    manual_feature = cache['manual_feature'][()]
    # print('#manual_feature:', manual_feature.shape, manual_feature.dtype)
    cache.close()
    # input()
    
    # filename_distri_h5py = path_directory + f'{sparse_name}/' + sparse_name + "_nnz_row_distribute.h5py"
    # cache = h5py.File(filename_distri_h5py, 'r')
    # nnz_row_distribution = cache['nnz_row_distribution'][()]
    # manual_feature = np.concatenate([manual_feature, nnz_row_distribution], axis=0)
    # print('#manual_feature:', manual_feature.shape, manual_feature.dtype)
    # cache.close()    
    
    # density_map_all.append(density_map)
    manual_feature_all.append(manual_feature)
    # nnz_number_all.append(nnz_number)
# f.close

with h5py.File(f'../data/32_csv.hdf5', 'w') as f:
    f.create_dataset('manual_feature',    data=manual_feature_all)
    # f.create_dataset('dense_matrix',      data=dense_matrix)
    # f.create_dataset('density_map',       data=density_map_all)
    # f.create_dataset('nnz_number',            data=nnz_number_all)